package com.fredhat.tvshowrenamer;

import java.util.Arrays;

/**
 * This value object represents a generic TV show.  Specific information on an episode level
 * is not defined here.
 * @author fred.drake
 *
 */
public class TVShow {
	private String name;
	private String[] nameRegexes;
	private String extension;
	private String tvComURL;
	private boolean separateSeasons;
	private String template;

	/**
	 * Constructs a TVShow with the given information
	 * @param name the TV show name
	 * @param tvComURL the TV.Com URL associated
	 * @param nameRegexes all regular expressions used to identify this show
	 * @param extension the file extension belonging to this show
	 */
	public TVShow(String name, String tvComURL, String[] nameRegexes,
			String extension, boolean separateSeasons, String template) {
		super();
		this.name = name;
		this.nameRegexes = nameRegexes;
		this.extension = extension;
		this.tvComURL = tvComURL;
		this.separateSeasons = separateSeasons;
		this.template = template;
	}

	public String getName() {
		return name;
	}

	public String getTvComURL() {
		return tvComURL;
	}

	public String[] getNameRegexes() {
		return nameRegexes;
	}
	
	public String getExtension() {
		return extension;
	}
	
	public boolean getSeparateSeasons() {
		return separateSeasons;
	}

	public String getTemplate() {
		return template;
	}
	
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((extension == null) ? 0 : extension.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + Arrays.hashCode(nameRegexes);
		result = prime * result + (separateSeasons ? 1231 : 1237);
		result = prime * result
				+ ((template == null) ? 0 : template.hashCode());
		result = prime * result
				+ ((tvComURL == null) ? 0 : tvComURL.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final TVShow other = (TVShow) obj;
		if (extension == null) {
			if (other.extension != null)
				return false;
		} else if (!extension.equals(other.extension))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (!Arrays.equals(nameRegexes, other.nameRegexes))
			return false;
		if (separateSeasons != other.separateSeasons)
			return false;
		if (template == null) {
			if (other.template != null)
				return false;
		} else if (!template.equals(other.template))
			return false;
		if (tvComURL == null) {
			if (other.tvComURL != null)
				return false;
		} else if (!tvComURL.equals(other.tvComURL))
			return false;
		return true;
	}	
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("[ TVShow name=").append(name);
		sb.append(", nameRegexes=").append(nameRegexes);
		sb.append(", tvComURL=").append(tvComURL);
		sb.append(", extension").append(extension);
		sb.append(", separateseasons=").append(separateSeasons);
		sb.append(", template=").append(template);
		sb.append(" ]");
		return sb.toString();
	}
}
